<template>
  <div class="admin-appointment-manage">
    <!-- 搜索栏 -->
    <el-card class="search-card">
      <div class="search-container">
        <div class="search-row">
          <div class="search-item">
            <label>病情描述：</label>
            <el-input 
              v-model="searchParams.conditionDescription" 
              placeholder="请输入病情描述" 
              clearable
              style="width: 200px;">
            </el-input>
          </div>
          
          <div class="search-item">
            <label>预约状态：</label>
            <div class="filter-buttons">
              <el-button 
                :type="searchParams.status === '' ? 'primary' : ''" 
                size="small"
                @click="searchParams.status = ''">
                全部
              </el-button>
              <el-button 
                :type="searchParams.status === '待赴约' ? 'primary' : ''" 
                size="small"
                @click="searchParams.status = '待赴约'">
                待赴约
              </el-button>
              <el-button 
                :type="searchParams.status === '已到店' ? 'primary' : ''" 
                size="small"
                @click="searchParams.status = '已到店'">
                已到店
              </el-button>
              <el-button 
                :type="searchParams.status === '已完成' ? 'primary' : ''" 
                size="small"
                @click="searchParams.status = '已完成'">
                已完成
              </el-button>
            </div>
          </div>
          
          <div class="search-item">
            <label>时间范围：</label>
            <el-date-picker
              v-model="dateRange"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              value-format="yyyy-MM-dd HH:mm:ss"
              style="width: 380px;">
            </el-date-picker>
          </div>
          
          <div class="search-actions">
            <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="handleReset">重置</el-button>
            <el-button type="warning" icon="el-icon-download" @click="handleExport">导出Excel</el-button>
          </div>
        </div>
      </div>
    </el-card>
    
    <!-- 预约列表 -->
    <el-card class="table-card">
      <div class="table-header">
        <h3>预约记录列表</h3>
        <span class="total-count">共 {{ total }} 条数据</span>
      </div>
      
      <el-table 
        :data="appointmentList" 
        v-loading="loading"
        stripe
        style="width: 100%">
        <el-table-column prop="id" label="预约ID" min-width="80" align="center"></el-table-column>
        
        <el-table-column prop="hospitalName" label="医院名称" min-width="180" show-overflow-tooltip></el-table-column>
        
        <el-table-column label="宠物信息" min-width="150">
          <template slot-scope="scope">
            <div>{{ scope.row.petName }}（{{ scope.row.petType }}）</div>
          </template>
        </el-table-column>
        
        <el-table-column prop="conditionDescription" label="病情描述" min-width="250" show-overflow-tooltip></el-table-column>
        
        <el-table-column label="病情图片" min-width="150" align="center">
          <template slot-scope="scope">
            <div class="image-stack" v-if="getImageList(scope.row.images).length > 0" @click="handleViewImages(scope.row)">
              <img 
                v-for="(img, index) in getImageList(scope.row.images).slice(0, 3)" 
                :key="index"
                :src="img" 
                :style="{ zIndex: 3 - index, left: index * 8 + 'px' }"
                class="stack-image">
              <span v-if="getImageList(scope.row.images).length > 3" class="image-count">+{{ getImageList(scope.row.images).length - 3 }}</span>
            </div>
            <span v-else style="color: #999;">暂无图片</span>
          </template>
        </el-table-column>
        
        <el-table-column label="预约时间" min-width="160">
          <template slot-scope="scope">
            <div>{{ formatDate(scope.row.appointmentDate) }}</div>
            <div style="color: #909399; font-size: 12px;">{{ scope.row.appointmentTime }}</div>
          </template>
        </el-table-column>
        
        <el-table-column prop="contactPhone" label="联系电话" min-width="130"></el-table-column>
        
        <el-table-column label="状态" min-width="100" align="center">
          <template slot-scope="scope">
            <el-tag 
              :type="getStatusType(scope.row.status)"
              size="medium">
              {{ scope.row.status }}
            </el-tag>
          </template>
        </el-table-column>
        
        <el-table-column prop="createTime" label="创建时间" min-width="160">
          <template slot-scope="scope">
            {{ formatDateTime(scope.row.createTime) }}
          </template>
        </el-table-column>
        
        <el-table-column label="操作" min-width="240" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button 
              type="text" 
              size="small" 
              icon="el-icon-view"
              @click="viewDetail(scope.row)">
              查看详情
            </el-button>
            <el-button 
              type="text" 
              size="small" 
              icon="el-icon-edit"
              style="color: #E6A23C;"
              @click="handleEdit(scope.row)">
              编辑
            </el-button>
            <el-button 
              v-if="scope.row.status === '已到店'"
              type="text" 
              size="small" 
              icon="el-icon-check"
              style="color: #67C23A;"
              @click="completeAppointment(scope.row)">
              已完成
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      
      <!-- 分页 -->
      <div class="pagination-container">
        <el-pagination
          background
          @current-change="handlePageChange"
          @size-change="handleSizeChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </el-card>
    
    <!-- 详情对话框 -->
    <el-dialog 
      title="预约详情" 
      :visible.sync="detailDialogVisible" 
      width="700px"
      :close-on-click-modal="false">
      <div class="detail-container" v-if="currentAppointment">
        <div class="detail-row">
          <div class="detail-item">
            <label>预约ID：</label>
            <span>{{ currentAppointment.id }}</span>
          </div>
          <div class="detail-item">
            <label>状态：</label>
            <el-tag :type="getStatusType(currentAppointment.status)" size="medium">
              {{ currentAppointment.status }}
            </el-tag>
          </div>
        </div>
        
        <div class="detail-row">
          <div class="detail-item full-width">
            <label>医院名称：</label>
            <span>{{ currentAppointment.hospitalName }}</span>
          </div>
        </div>
        
        <div class="detail-row">
          <div class="detail-item">
            <label>宠物名称：</label>
            <span>{{ currentAppointment.petName }}</span>
          </div>
          <div class="detail-item">
            <label>宠物类型：</label>
            <span>{{ currentAppointment.petType }}</span>
          </div>
        </div>
        
        <div class="detail-row">
          <div class="detail-item full-width">
            <label>病情描述：</label>
            <div class="detail-value">{{ currentAppointment.conditionDescription }}</div>
          </div>
        </div>
        
        <div class="detail-row" v-if="currentAppointment.images">
          <div class="detail-item full-width">
            <label>病情图片：</label>
            <div class="detail-images">
              <el-image 
                v-for="(image, index) in getImageList(currentAppointment.images)" 
                :key="index"
                :src="image"
                :preview-src-list="getImageList(currentAppointment.images)"
                :initial-index="index"
                fit="cover"
                style="width: 100px; height: 100px; margin-right: 10px; border-radius: 6px; cursor: pointer;">
                <div slot="error" class="image-error">
                  <i class="el-icon-picture-outline"></i>
                </div>
              </el-image>
            </div>
          </div>
        </div>
        
        <div class="detail-row">
          <div class="detail-item">
            <label>预约日期：</label>
            <span>{{ formatDate(currentAppointment.appointmentDate) }}</span>
          </div>
          <div class="detail-item">
            <label>预约时间：</label>
            <span>{{ currentAppointment.appointmentTime }}</span>
          </div>
        </div>
        
        <div class="detail-row">
          <div class="detail-item">
            <label>联系电话：</label>
            <span>{{ currentAppointment.contactPhone }}</span>
          </div>
          <div class="detail-item">
            <label>创建时间：</label>
            <span>{{ formatDateTime(currentAppointment.createTime) }}</span>
          </div>
        </div>
      </div>
      
      <div slot="footer" class="dialog-footer">
        <el-button @click="detailDialogVisible = false">关闭</el-button>
        <el-button 
          v-if="currentAppointment && currentAppointment.status === '已到店'"
          type="success" 
          icon="el-icon-check"
          @click="completeAppointmentFromDialog">
          标记为已完成
        </el-button>
      </div>
    </el-dialog>
    
    <!-- 图片预览对话框 -->
    <el-dialog 
      :visible.sync="imagePreviewVisible" 
      width="800px"
      :close-on-click-modal="true"
      custom-class="image-preview-dialog">
      <div class="image-preview-container">
        <el-carousel 
          :initial-index="currentImageIndex"
          height="500px"
          indicator-position="outside">
          <el-carousel-item v-for="(image, index) in previewImages" :key="index">
            <div class="carousel-image-wrapper">
              <el-image 
                :src="image"
                fit="contain"
                style="width: 100%; height: 100%;">
                <div slot="error" class="image-error">
                  <i class="el-icon-picture-outline"></i>
                  <div>加载失败</div>
                </div>
              </el-image>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </el-dialog>

    <!-- 编辑对话框 -->
    <el-dialog 
      title="编辑预约记录" 
      :visible.sync="editDialogVisible" 
      width="900px"
      :close-on-click-modal="false">
      <el-form :model="editForm" :rules="editRules" ref="editForm" label-width="120px">
        <el-form-item label="宠物名称" prop="petName">
          <el-input v-model="editForm.petName" placeholder="请输入宠物名称"></el-input>
        </el-form-item>
        
        <el-form-item label="宠物类型" prop="petType">
          <div class="filter-buttons">
            <el-button 
              :type="editForm.petType === '狗' ? 'primary' : ''" 
              size="small"
              @click="editForm.petType = '狗'">
              狗
            </el-button>
            <el-button 
              :type="editForm.petType === '猫' ? 'primary' : ''" 
              size="small"
              @click="editForm.petType = '猫'">
              猫
            </el-button>
          </div>
        </el-form-item>
        
        <el-form-item label="病情描述" prop="conditionDescription">
          <el-input 
            v-model="editForm.conditionDescription" 
            type="textarea"
            :rows="4"
            placeholder="请输入病情描述">
          </el-input>
        </el-form-item>
        
        <el-form-item label="病情图片">
          <div class="upload-container">
            <div class="image-list">
              <div 
                v-for="(img, index) in editForm.imageList" 
                :key="index" 
                class="image-item">
                <img :src="img" alt="病情图片">
                <div class="image-overlay">
                  <i class="el-icon-zoom-in" @click="handlePreviewEditImage(index)"></i>
                  <i class="el-icon-delete" @click="handleRemoveEditImage(index)"></i>
                </div>
              </div>
              
              <el-upload
                v-if="editForm.imageList.length < 5"
                class="image-uploader"
                action=""
                :show-file-list="false"
                :before-upload="handleBeforeUpload"
                :http-request="handleUploadEditImage">
                <i class="el-icon-plus upload-icon"></i>
                <div class="upload-text">上传图片</div>
              </el-upload>
            </div>
            <div class="upload-tip">最多可上传5张图片，支持jpg、png格式，单张图片不超过2MB</div>
          </div>
        </el-form-item>
        
        <el-form-item label="预约日期" prop="appointmentDate">
          <el-date-picker
            v-model="editForm.appointmentDate"
            type="date"
            placeholder="选择预约日期"
            value-format="yyyy-MM-dd"
            style="width: 100%;">
          </el-date-picker>
        </el-form-item>
        
        <el-form-item label="预约时间" prop="appointmentTime">
          <el-time-select
            v-model="editForm.appointmentTime"
            :picker-options="{
              start: '08:00',
              step: '00:30',
              end: '18:00'
            }"
            placeholder="选择预约时间"
            style="width: 100%;">
          </el-time-select>
        </el-form-item>
        
        <el-form-item label="联系电话" prop="contactPhone">
          <el-input v-model="editForm.contactPhone" placeholder="请输入联系电话"></el-input>
        </el-form-item>
        
        <el-form-item label="状态" prop="status">
          <div class="filter-buttons">
            <el-button 
              :type="editForm.status === '待赴约' ? 'primary' : ''" 
              size="small"
              @click="editForm.status = '待赴约'">
              待赴约
            </el-button>
            <el-button 
              :type="editForm.status === '已到店' ? 'primary' : ''" 
              size="small"
              @click="editForm.status = '已到店'">
              已到店
            </el-button>
            <el-button 
              :type="editForm.status === '已完成' ? 'primary' : ''" 
              size="small"
              @click="editForm.status = '已完成'">
              已完成
            </el-button>
          </div>
        </el-form-item>
      </el-form>
      
      <div slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="handleSubmitEdit" :loading="editLoading">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getAdminAppointmentList, completeAppointment, exportAppointments, adminUpdateAppointment } from '@/api/appointment';
import { uploadFile } from '@/api/file';

export default {
  name: 'AdminAppointmentManage',
  data() {
    return {
      searchParams: {
        conditionDescription: '',
        status: ''
      },
      dateRange: [],
      appointmentList: [],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      loading: false,
      detailDialogVisible: false,
      currentAppointment: null,
      imagePreviewVisible: false,
      previewImages: [],
      currentImageIndex: 0,
      
      // 编辑对话框
      editDialogVisible: false,
      editLoading: false,
      editForm: {
        id: null,
        petName: '',
        petType: '狗',
        conditionDescription: '',
        imageList: [],
        appointmentDate: '',
        appointmentTime: '',
        contactPhone: '',
        status: '待赴约'
      },
      editRules: {
        petName: [
          { required: true, message: '请输入宠物名称', trigger: 'blur' }
        ],
        petType: [
          { required: true, message: '请选择宠物类型', trigger: 'change' }
        ],
        conditionDescription: [
          { required: true, message: '请输入病情描述', trigger: 'blur' }
        ],
        appointmentDate: [
          { required: true, message: '请选择预约日期', trigger: 'change' }
        ],
        appointmentTime: [
          { required: true, message: '请选择预约时间', trigger: 'change' }
        ],
        contactPhone: [
          { required: true, message: '请输入联系电话', trigger: 'blur' },
          { pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号码', trigger: 'blur' }
        ],
        status: [
          { required: true, message: '请选择状态', trigger: 'change' }
        ]
      }
    };
  },
  created() {
    this.loadAppointments();
  },
  methods: {
    // 加载预约列表
    async loadAppointments() {
      this.loading = true;
      try {
        const params = {
          page: this.currentPage,
          size: this.pageSize
        };
        
        if (this.searchParams.conditionDescription) {
          params.conditionDescription = this.searchParams.conditionDescription;
        }
        if (this.searchParams.status) {
          params.status = this.searchParams.status;
        }
        if (this.dateRange && this.dateRange.length === 2) {
          params.startTime = this.dateRange[0];
          params.endTime = this.dateRange[1];
        }
        
        const response = await getAdminAppointmentList(params);
        if (response.data.success) {
          this.appointmentList = response.data.data.records || [];
          this.total = response.data.data.total || 0;
        } else {
          this.$notify({
            title: '失败',
            message: response.data.message || '加载预约记录失败',
            type: 'error',
            duration: 2000
          });
        }
      } catch (error) {
        console.error(error);
        this.$notify({
          title: '错误',
          message: '加载预约记录失败，请稍后重试',
          type: 'error',
          duration: 2000
        });
      } finally {
        this.loading = false;
      }
    },
    
    // 搜索
    handleSearch() {
      this.currentPage = 1;
      this.loadAppointments();
    },
    
    // 重置
    handleReset() {
      this.searchParams = {
        conditionDescription: '',
        status: ''
      };
      this.dateRange = [];
      this.handleSearch();
    },
    
    // 翻页
    handlePageChange(page) {
      this.currentPage = page;
      this.loadAppointments();
    },
    
    // 改变每页大小
    handleSizeChange(size) {
      this.pageSize = size;
      this.currentPage = 1;
      this.loadAppointments();
    },
    
    // 获取状态类型
    getStatusType(status) {
      const typeMap = {
        '待赴约': 'warning',
        '已到店': 'primary',
        '已完成': 'success'
      };
      return typeMap[status] || 'info';
    },
    
    // 获取图片列表
    getImageList(images) {
      if (!images) {
        return [];
      }
      return images.split(',');
    },
    
    // 查看图片
    handleViewImages(row) {
      const images = this.getImageList(row.images);
      if (images.length > 0) {
        this.previewImages = images;
        this.currentImageIndex = 0;
        this.imagePreviewVisible = true;
      }
    },
    
    // 显示图片预览
    showImagePreview(images, index) {
      this.previewImages = this.getImageList(images);
      this.currentImageIndex = index;
      this.imagePreviewVisible = true;
    },
    
    // 格式化日期
    formatDate(date) {
      if (!date) return '';
      const d = new Date(date);
      const year = d.getFullYear();
      const month = String(d.getMonth() + 1).padStart(2, '0');
      const day = String(d.getDate()).padStart(2, '0');
      return `${year}-${month}-${day}`;
    },
    
    // 格式化日期时间
    formatDateTime(datetime) {
      if (!datetime) return '';
      const d = new Date(datetime);
      const year = d.getFullYear();
      const month = String(d.getMonth() + 1).padStart(2, '0');
      const day = String(d.getDate()).padStart(2, '0');
      const hours = String(d.getHours()).padStart(2, '0');
      const minutes = String(d.getMinutes()).padStart(2, '0');
      return `${year}-${month}-${day} ${hours}:${minutes}`;
    },
    
    // 查看详情
    viewDetail(appointment) {
      this.currentAppointment = appointment;
      this.detailDialogVisible = true;
    },
    
    // 编辑预约
    handleEdit(appointment) {
      this.editForm = {
        id: appointment.id,
        petName: appointment.petName,
        petType: appointment.petType,
        conditionDescription: appointment.conditionDescription,
        imageList: this.getImageList(appointment.images),
        appointmentDate: this.formatDate(appointment.appointmentDate),
        appointmentTime: appointment.appointmentTime,
        contactPhone: appointment.contactPhone,
        status: appointment.status
      };
      this.editDialogVisible = true;
      this.$nextTick(() => {
        if (this.$refs.editForm) {
          this.$refs.editForm.clearValidate();
        }
      });
    },
    
    // 上传前校验
    handleBeforeUpload(file) {
      const isImage = file.type.startsWith('image/');
      const isLt2M = file.size / 1024 / 1024 < 2;
      
      if (!isImage) {
        this.$notify({
          title: '错误',
          message: '只能上传图片文件',
          type: 'error',
          duration: 2000
        });
        return false;
      }
      
      if (!isLt2M) {
        this.$notify({
          title: '错误',
          message: '图片大小不能超过2MB',
          type: 'error',
          duration: 2000
        });
        return false;
      }
      
      return true;
    },
    
    // 上传编辑图片
    async handleUploadEditImage(params) {
      try {
        const response = await uploadFile(params.file);
        if (response.data.success) {
          const imageUrl = response.data.data;
          this.editForm.imageList.push(imageUrl);
          this.$notify({
            title: '成功',
            message: '图片上传成功',
            type: 'success',
            duration: 2000
          });
        } else {
          this.$notify({
            title: '错误',
            message: response.data.message || '图片上传失败',
            type: 'error',
            duration: 2000
          });
        }
      } catch (error) {
        console.error(error);
        this.$notify({
          title: '错误',
          message: '图片上传失败',
          type: 'error',
          duration: 2000
        });
      }
    },
    
    // 删除编辑图片
    handleRemoveEditImage(index) {
      this.editForm.imageList.splice(index, 1);
    },
    
    // 预览编辑图片
    handlePreviewEditImage(index) {
      this.previewImages = [...this.editForm.imageList];
      this.currentImageIndex = index;
      this.imagePreviewVisible = true;
    },
    
    // 提交编辑
    handleSubmitEdit() {
      this.$refs.editForm.validate(async (valid) => {
        if (valid) {
          this.editLoading = true;
          try {
            const submitData = {
              id: this.editForm.id,
              petName: this.editForm.petName,
              petType: this.editForm.petType,
              conditionDescription: this.editForm.conditionDescription,
              images: this.editForm.imageList.join(','),
              appointmentDate: this.editForm.appointmentDate,
              appointmentTime: this.editForm.appointmentTime,
              contactPhone: this.editForm.contactPhone,
              status: this.editForm.status
            };
            
            const response = await adminUpdateAppointment(submitData);
            if (response.data.success) {
              this.$notify({
                title: '成功',
                message: '更新成功',
                type: 'success',
                duration: 2000
              });
              this.editDialogVisible = false;
              this.loadAppointments();
            } else {
              this.$notify({
                title: '失败',
                message: response.data.message || '更新失败',
                type: 'error',
                duration: 2000
              });
            }
          } catch (error) {
            console.error(error);
            this.$notify({
              title: '错误',
              message: '更新失败，请稍后重试',
              type: 'error',
              duration: 2000
            });
          } finally {
            this.editLoading = false;
          }
        }
      });
    },
    
    // 完成预约
    async completeAppointment(appointment) {
      try {
        const confirm = await this.$confirm('确认将此预约标记为已完成吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'success'
        });
        
        if (confirm) {
          const response = await completeAppointment(appointment.id);
          if (response.data.success) {
            this.$notify({
              title: '成功',
              message: '标记完成成功',
              type: 'success',
              duration: 2000
            });
            this.loadAppointments();
          } else {
            this.$notify({
              title: '失败',
              message: response.data.message || '标记完成失败',
              type: 'error',
              duration: 2000
            });
          }
        }
      } catch (error) {
        if (error !== 'cancel') {
          console.error(error);
          this.$notify({
            title: '错误',
            message: '标记完成失败，请稍后重试',
            type: 'error',
            duration: 2000
          });
        }
      }
    },
    
    // 从详情对话框完成预约
    async completeAppointmentFromDialog() {
      await this.completeAppointment(this.currentAppointment);
      this.detailDialogVisible = false;
    },
    
    // 导出Excel
    handleExport() {
      try {
        const params = {};
        
        if (this.searchParams.conditionDescription) {
          params.conditionDescription = this.searchParams.conditionDescription;
        }
        if (this.searchParams.status) {
          params.status = this.searchParams.status;
        }
        if (this.dateRange && this.dateRange.length === 2) {
          params.startTime = this.dateRange[0];
          params.endTime = this.dateRange[1];
        }
        
        exportAppointments(params);
        
        this.$notify({
          title: '提示',
          message: '正在导出Excel文件...',
          type: 'info',
          duration: 2000
        });
      } catch (error) {
        console.error(error);
        this.$notify({
          title: '错误',
          message: '导出失败，请稍后重试',
          type: 'error',
          duration: 2000
        });
      }
    }
  }
};
</script>

<style scoped>
.admin-appointment-manage {
  padding: 20px;
  background: #f5f7fa;
  min-height: calc(100vh - 60px);
}

/* 搜索卡片 */
.search-card {
  margin-bottom: 20px;
  border-radius: 8px;
}

.search-container {
  padding: 10px 0;
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-item label {
  font-size: 14px;
  color: #606266;
  font-weight: 500;
  white-space: nowrap;
}

.filter-buttons {
  display: flex;
  gap: 8px;
}

.search-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

/* 表格卡片 */
.table-card {
  border-radius: 8px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #e4e7ed;
}

.table-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #303133;
  margin: 0;
}

.total-count {
  font-size: 14px;
  color: #909399;
}

/* 图片层叠样式 */
.image-stack {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
  cursor: pointer;
}

.stack-image {
  position: absolute;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border: 2px solid white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: transform 0.3s;
}

.image-stack:hover .stack-image {
  transform: translateY(-5px);
}

.image-count {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 12px;
  z-index: 10;
}

.image-error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background: #f5f7fa;
  color: #909399;
}

.image-error i {
  font-size: 24px;
}

/* 分页 */
.pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #e4e7ed;
}

/* 详情对话框 */
.detail-container {
  padding: 10px 0;
}

.detail-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.detail-item {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.detail-item.full-width {
  flex: none;
  width: 100%;
}

.detail-item label {
  font-size: 14px;
  color: #909399;
  font-weight: 500;
  white-space: nowrap;
  min-width: 80px;
}

.detail-item span {
  font-size: 14px;
  color: #303133;
}

.detail-value {
  font-size: 14px;
  color: #303133;
  line-height: 1.6;
  flex: 1;
}

.detail-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 图片预览对话框 */
.image-preview-dialog {
  background: rgba(0, 0, 0, 0.8);
}

.image-preview-container {
  padding: 20px;
}

.carousel-image-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background: #000;
}

/* 上传容器 */
.upload-container {
  width: 100%;
}

.image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.image-item {
  position: relative;
  width: 120px;
  height: 120px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  overflow: hidden;
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  opacity: 0;
  transition: opacity 0.3s;
}

.image-item:hover .image-overlay {
  opacity: 1;
}

.image-overlay i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: transform 0.3s;
}

.image-overlay i:hover {
  transform: scale(1.2);
}

.image-uploader {
  width: 120px;
  height: 120px;
  border: 1px dashed #d9d9d9;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: border-color 0.3s;
}

.image-uploader:hover {
  border-color: #409eff;
}

.upload-icon {
  font-size: 28px;
  color: #8c939d;
}

.upload-text {
  margin-top: 8px;
  color: #8c939d;
  font-size: 12px;
}

.upload-tip {
  color: #999;
  font-size: 12px;
  line-height: 1.5;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-item {
    width: 100%;
  }
  
  .search-item .el-input,
  .search-item .el-date-picker {
    width: 100% !important;
  }
  
  .search-actions {
    margin-left: 0;
    justify-content: flex-start;
  }
  
  .filter-buttons {
    flex-wrap: wrap;
  }
}
</style>

